﻿using System.Collections.Generic;
using UnityEngine;
using WorldMapBase.Tile.Pool;

namespace WorldMapBase.Tile
{
    public class TrafficObject : WorldObject
    {
        public MapChunckTrafficCar car;
        public MapChunckTrafficLight light;
        public override void OnCreate(int lodIndex, int resID, Transform tf)
        {
            base.OnCreate(lodIndex, resID, tf);
            car = GetRefTrans.gameObject.GetComponent<MapChunckTrafficCar>();
            if (car)
            {
                car.OnCreated();
            }
            light = GetRefTrans.gameObject.GetComponent<MapChunckTrafficLight>();
            GetRefTrans.gameObject.transform.localScale = Vector3.one;
        }

        public override void OnRecovered()
        {
            if (car) car.OnReset();
            if (light) light.OnReset();
            car = null;
            light = null;
            //ClassPoolManager.RecoverTrafficObject(this);
        }
    }
}
